package com.hzlj.position.job.job;

import com.fz.common.redis.annotation.SyncLock;
import com.hzlj.position.locate.service.ReportInitiativeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class ReportInitiativeJob {
    @Resource
    private ReportInitiativeService reportInitiativeService;

    /**
     * 每隔1个小时一次
     */
    @SyncLock(lockMs = 60000)
    @Scheduled(cron = "${job.report.initiative.sync:0 0 * * * ?}")
    public void sync() {
        long start = System.currentTimeMillis();
        log.info("任务开始执行[人脸签到同步]");
        try {
            Integer size = reportInitiativeService.sync();
            log.info("任务结束执行[人脸签到同步],size={},cost={}", size, System.currentTimeMillis() - start);
        } catch (Exception e) {
            log.error("任务结束执行[人脸签到同步]失败,cost={}", System.currentTimeMillis() - start, e);
        }

    }


}
